package com.cf.controller;

import com.cf.entity.Power;
import com.cf.entity.Result;
import com.cf.service.PowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class PowerController {
    @Autowired
    private PowerService powerService;
    @RequestMapping("/selectOneTwoPower")
    public Object selectOneTwoPower(){
        List<Power> powers = powerService.selectOneTwoPower();
        if (powers.size()!=0){
            return new Result(200,"查询成功",powers);
        }else {
            return new Result(400,"查询失败",null);
        }
    }
    @RequestMapping("/selectPowersByUid")
    public Object selectPowersByUid(long id){
        List<Power> powers = powerService.selectPowersByUid(id);
        if (powers.size()!=0){
            return new Result(200,"查询成功",powers);
        }else {
            return new Result(400,"查询失败",null);
        }
    }
}
